package stool.juc.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author Felix YF Dong
 * @Description
 * @Date 2023/2/20
 */
public class SimpleDemo {

    public static void main(String[] args) {
        ExecutorService threadpool1= Executors.newFixedThreadPool(5);// 五个受理窗口，一池五线程
        ExecutorService threadpool2= Executors.newSingleThreadExecutor();// 一池一线程
        ExecutorService threadpool3= Executors.newCachedThreadPool();// 一池N线程,自动扩展
        try {
            for (int i = 0; i <=10 ; i++) { //10个客户
                threadpool1.execute(()->{
                    System.out.println(Thread.currentThread().getName()+" 办理业务");
                });
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            threadpool1.shutdown();
        }
    }
}
